<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>springboot进行web开发总结 | 月藤的博客</title>
    <meta name="generator" content="VuePress 1.8.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css">
    <meta name="description" content="简单的介绍">
    
    <link rel="preload" href="/assets/css/0.styles.a2e941e0.css" as="style"><link rel="preload" href="/assets/js/app.54ea76a2.js" as="script"><link rel="preload" href="/assets/js/2.c554ece5.js" as="script"><link rel="preload" href="/assets/js/24.87aae001.js" as="script"><link rel="prefetch" href="/assets/js/10.95d63e51.js"><link rel="prefetch" href="/assets/js/11.26e082be.js"><link rel="prefetch" href="/assets/js/12.1f62021c.js"><link rel="prefetch" href="/assets/js/13.9096527c.js"><link rel="prefetch" href="/assets/js/14.86142c70.js"><link rel="prefetch" href="/assets/js/15.1adeebc5.js"><link rel="prefetch" href="/assets/js/16.efcc79e4.js"><link rel="prefetch" href="/assets/js/17.74da5698.js"><link rel="prefetch" href="/assets/js/18.fd808b3a.js"><link rel="prefetch" href="/assets/js/19.8dafe26f.js"><link rel="prefetch" href="/assets/js/20.aed54ab4.js"><link rel="prefetch" href="/assets/js/21.341a5670.js"><link rel="prefetch" href="/assets/js/22.ab8b375c.js"><link rel="prefetch" href="/assets/js/23.28489470.js"><link rel="prefetch" href="/assets/js/25.211ca3bf.js"><link rel="prefetch" href="/assets/js/26.afa4c8f0.js"><link rel="prefetch" href="/assets/js/27.9b98f6f3.js"><link rel="prefetch" href="/assets/js/28.93298733.js"><link rel="prefetch" href="/assets/js/29.e8c038c4.js"><link rel="prefetch" href="/assets/js/3.9d562ae1.js"><link rel="prefetch" href="/assets/js/30.27939f01.js"><link rel="prefetch" href="/assets/js/31.6a9774e8.js"><link rel="prefetch" href="/assets/js/32.f698e967.js"><link rel="prefetch" href="/assets/js/33.5ba4bfb8.js"><link rel="prefetch" href="/assets/js/34.dca90861.js"><link rel="prefetch" href="/assets/js/35.768c1bb2.js"><link rel="prefetch" href="/assets/js/36.6b0a867f.js"><link rel="prefetch" href="/assets/js/37.61156e90.js"><link rel="prefetch" href="/assets/js/38.e390246c.js"><link rel="prefetch" href="/assets/js/39.0fbd0dd1.js"><link rel="prefetch" href="/assets/js/4.e18bc6a8.js"><link rel="prefetch" href="/assets/js/40.4252699c.js"><link rel="prefetch" href="/assets/js/41.2e5b5840.js"><link rel="prefetch" href="/assets/js/42.8fe886c7.js"><link rel="prefetch" href="/assets/js/43.7a4b0851.js"><link rel="prefetch" href="/assets/js/44.93c2313d.js"><link rel="prefetch" href="/assets/js/45.33dcea60.js"><link rel="prefetch" href="/assets/js/46.681fdf10.js"><link rel="prefetch" href="/assets/js/47.a842a141.js"><link rel="prefetch" href="/assets/js/48.9a03ba74.js"><link rel="prefetch" href="/assets/js/49.a50266b1.js"><link rel="prefetch" href="/assets/js/5.dc6a2d8c.js"><link rel="prefetch" href="/assets/js/50.f2a42406.js"><link rel="prefetch" href="/assets/js/51.444cc3d8.js"><link rel="prefetch" href="/assets/js/52.cf2befd8.js"><link rel="prefetch" href="/assets/js/53.fbe609f8.js"><link rel="prefetch" href="/assets/js/54.a43fb514.js"><link rel="prefetch" href="/assets/js/55.d0c11641.js"><link rel="prefetch" href="/assets/js/56.c6f114d9.js"><link rel="prefetch" href="/assets/js/57.cc386420.js"><link rel="prefetch" href="/assets/js/58.e747d0f6.js"><link rel="prefetch" href="/assets/js/6.c1fd48f0.js"><link rel="prefetch" href="/assets/js/7.32b39b92.js"><link rel="prefetch" href="/assets/js/8.e2284671.js"><link rel="prefetch" href="/assets/js/9.8def3992.js">
    <link rel="stylesheet" href="/assets/css/0.styles.a2e941e0.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">月藤的博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="https://ziphold.gitee.io/blog/#/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  旧博客（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://rattonlzh.github.io/homepage/homepage.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  常用网址导航（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/知识点总结/springboot总结.html" class="nav-link">
  zh-CN
</a></li><li class="dropdown-item"><!----> <a href="/en/" class="nav-link">
  en-US
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><div class="avatar"><img src="/assets/img/avatar.2b77755b.png" alt srcset></div> <div style="z-index: 999"><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="298" height="52" src="//music.163.com/outchain/player?type=2&id=28283137&auto=1&height=32"></iframe></div> <nav class="nav-links"><div class="nav-item"><a href="https://ziphold.gitee.io/blog/#/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  旧博客（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><a href="https://rattonlzh.github.io/homepage/homepage.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  常用网址导航（停止更新）
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Select language" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Select language" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/知识点总结/springboot总结.html" class="nav-link">
  zh-CN
</a></li><li class="dropdown-item"><!----> <a href="/en/" class="nav-link">
  en-US
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>随便说说</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>知识点总结</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/知识点总结/git总结.html" class="sidebar-link">git总结</a></li><li><a href="/知识点总结/java单元测试总结.html" class="sidebar-link">java测试</a></li><li><a href="/知识点总结/jquery总结.html" class="sidebar-link">jquery初探</a></li><li><a href="/知识点总结/js总结.html" class="sidebar-link">js易错点</a></li><li><a href="/知识点总结/kotlin语法总结.html" class="sidebar-link">kotlin语法入门</a></li><li><a href="/知识点总结/latex总结.html" class="sidebar-link">latex常用代码</a></li><li><a href="/知识点总结/PS总结.html" class="sidebar-link">PS总结</a></li><li><a href="/知识点总结/springboot总结.html" class="active sidebar-link">springboot进行web开发总结</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#开发环境清单" class="sidebar-link">开发环境清单</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#框架使用手册" class="sidebar-link">框架使用手册</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#java环境变量的配置" class="sidebar-link">java环境变量的配置</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#配置intellij-idea" class="sidebar-link">配置Intellij idea</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#maven配置" class="sidebar-link">maven配置</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#mysql配置" class="sidebar-link">mysql配置</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#创建springboot工程" class="sidebar-link">创建springboot工程</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#测试" class="sidebar-link">测试</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#部署注意事项" class="sidebar-link">部署注意事项</a></li><li class="sidebar-sub-header"><a href="/知识点总结/springboot总结.html#前后端分离-不分离" class="sidebar-link">前后端分离/不分离</a></li></ul></li><li><a href="/知识点总结/thinkphp总结.html" class="sidebar-link">thinkphp入坑</a></li><li><a href="/知识点总结/uml软件建模总结.html" class="sidebar-link">uml软件建模总结</a></li><li><a href="/知识点总结/人工智能总结.html" class="sidebar-link">人工智能总结</a></li><li><a href="/知识点总结/大数据软件工程总结.html" class="sidebar-link">大数据软件工程总结</a></li><li><a href="/知识点总结/常用快捷键总结.html" class="sidebar-link">第一篇博客</a></li><li><a href="/知识点总结/数字图像处理总结.html" class="sidebar-link">数字图像处理知识点</a></li><li><a href="/知识点总结/数据库应用理论总结.html" class="sidebar-link">数据库应用复习</a></li><li><a href="/知识点总结/数据库系统概念总结.html" class="sidebar-link">数据库系统概念总结</a></li><li><a href="/知识点总结/数据挖掘总结.html" class="sidebar-link">数据挖掘总结</a></li><li><a href="/知识点总结/设计模式总结.html" class="sidebar-link">设计模式</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>考研专区</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>读书笔记</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开发资料</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>配置记录</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>思维导图</span> <span class="arrow right"></span></p> <!----></section></li><li><a href="/friend_link.html" class="sidebar-link">友情链接</a></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="springboot进行web开发总结"><a href="#springboot进行web开发总结" class="header-anchor">#</a> springboot进行web开发总结</h1> <hr> <h2 id="开发环境清单"><a href="#开发环境清单" class="header-anchor">#</a> 开发环境清单</h2> <ol><li>java: jdk1.8.0_172以上</li> <li>IDE: intellj idea(可以创建springboot工程)</li> <li>项目依赖构建工具: maven3以上</li> <li>数据库: mysql5.7</li> <li>前端框架: bootstrap4+jquery3</li></ol> <h2 id="框架使用手册"><a href="#框架使用手册" class="header-anchor">#</a> 框架使用手册</h2> <ul><li><p>后端框架</p> <ul><li><a href="https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/" target="_blank" rel="noopener noreferrer">springboot2.3.1.RELEASE<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>：是为了简化spring配置而出现的框架</li></ul></li> <li><p>持久层框架</p> <ul><li><a href="https://mybatis.org/mybatis-3/zh/getting-started.html" target="_blank" rel="noopener noreferrer">mymatis<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> ：通过手撕SQL语句与接口方法映射，可以做到更灵活的查询，在联合多表查询比较有优势</li></ul></li> <li><p>网页模板渲染引擎</p> <ul><li><a href="https://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.pdf" target="_blank" rel="noopener noreferrer">thymleaf3<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li> <li><p>日志框架</p> <ul><li><p>接口层：<a href="http://slf4j.org/manual.html" target="_blank" rel="noopener noreferrer">slf4j<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p>实现层：<a href="http://logback.qos.ch/manual/introduction.html" target="_blank" rel="noopener noreferrer">logback<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li></ul></li> <li><p>前端框架</p> <ul><li><a href="https://getbootstrap.com/docs/4.3/content/typography/" target="_blank" rel="noopener noreferrer">bootstrap<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>:负责快速搭建界面</li> <li><a href="https://jquery.cuishifeng.cn/index.html" target="_blank" rel="noopener noreferrer">jquery<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>:负责ajax请求,操作dom结点等</li></ul></li></ul> <h2 id="java环境变量的配置"><a href="#java环境变量的配置" class="header-anchor">#</a> java环境变量的配置</h2> <ol><li>**JAVA_HOME:**值为jdk的安装目录,java可以通过这个变量找到里面的jre</li> <li>**CLASSPATH:**以前网上的java教程总会让人设置classpath变量. classpath作用是告诉java去哪里搜索class文件,不设置时也会默认在当前目录查找. 主流IDE均支持导入第三方库的classpath路径, 因此不再推荐使用classpath环境变量</li> <li>**Path:**追加 <code>%JAVA_HOME%\bin</code>路径,以便可以通过命令行运行java命令</li></ol> <h2 id="配置intellij-idea"><a href="#配置intellij-idea" class="header-anchor">#</a> 配置Intellij idea</h2> <h3 id="设置file-encoding"><a href="#设置file-encoding" class="header-anchor">#</a> 设置file encoding</h3> <p>file-&gt;settings-&gt;editor-&gt;file encodings</p> <p>global encoding: utf8</p> <p>project encoding:utf8</p> <p>Default encoding for properties files:utf8</p> <p>勾选transparent native-to-ascii conversion</p> <h3 id="设置vm-options"><a href="#设置vm-options" class="header-anchor">#</a> 设置vm options</h3> <p>打开idea-&gt;help-&gt;edit custom vm options-&gt;设置 <code>-Xmx</code>参数</p> <p><img src="/assets/img/image-20200715202511103.436e62c2.png" alt="image-20200715202511103"></p> <p>虽然你的电脑配置很高,但是运行idea仍然感觉很卡,这是因为idea默认运行的最大堆内存(-Xmx)默认是750m,你可以把这个参数调的更大</p> <p>例如<code>-Xmx2048m</code>表示运行idea的jvm的最大堆内存为2048m,如果你的电脑的内存足够,可以调的更大以换取更好的性能</p> <h2 id="maven配置"><a href="#maven配置" class="header-anchor">#</a> maven配置</h2> <p>默认用户配置文件: <code>用户目录\.m2\settings.xml</code>，如果没有可以自行创建，增加以下配置：</p> <div class="language-xml extra-class"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>settings</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/SETTINGS/1.0.0<span class="token punctuation">&quot;</span></span>
          <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
          <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!--省略无关部分...--&gt;</span>
     <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>localRepository</span><span class="token punctuation">&gt;</span></span>E:\apache-maven-3.5.4\repo<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>localRepository</span><span class="token punctuation">&gt;</span></span> <span class="token comment">&lt;!--请替换成你自己定义的依赖包保存位置--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirrors</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirror</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>id</span><span class="token punctuation">&gt;</span></span>nexus-aliyun<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>id</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>Nexus aliyun<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>url</span><span class="token punctuation">&gt;</span></span>http://maven.aliyun.com/nexus/content/groups/public/<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>url</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirrorOf</span><span class="token punctuation">&gt;</span></span>central<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirrorOf</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirror</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirrors</span><span class="token punctuation">&gt;</span></span>  

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>profiles</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>profile</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>id</span><span class="token punctuation">&gt;</span></span>jdk-1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>id</span><span class="token punctuation">&gt;</span></span>

            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activation</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activeByDefault</span><span class="token punctuation">&gt;</span></span>true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activeByDefault</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>jdk</span><span class="token punctuation">&gt;</span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>jdk</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activation</span><span class="token punctuation">&gt;</span></span>

            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.compilerVersion</span><span class="token punctuation">&gt;</span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.compilerVersion</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>profile</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>profiles</span><span class="token punctuation">&gt;</span></span>
     <span class="token comment">&lt;!--省略无关部分...--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>setting</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><p>以上配置作用：</p> <ol><li>设置本地仓库路径。maven下载的jar包都会保存到本地仓库。默认下载位置时 <code>用户目录\.m2\repository</code>，如果你和我一样c盘空间严重不足（剩余容量不到20G），强烈建议更改到其他盘</li> <li>设置镜像仓库,通过使用国内服务器的镜像仓库代替国外服务器的资源解决网络延迟的问题</li> <li>指定jdk的版本,确保不会发生下载的jar包的编译版本与本地jdk一致</li></ol> <h2 id="mysql配置"><a href="#mysql配置" class="header-anchor">#</a> mysql配置</h2> <p>以root身份登录到mysql</p> <h3 id="设置数据库时区"><a href="#设置数据库时区" class="header-anchor">#</a> 设置数据库时区</h3> <div class="language-mysql extra-class"><pre class="language-text"><code>set global time_zone='+8:00';# 设置时区为东八区
show variables like '%time_zone%';# 查看时区
</code></pre></div><h3 id="创建数据库"><a href="#创建数据库" class="header-anchor">#</a> 创建数据库</h3> <div class="language-mysql extra-class"><pre class="language-text"><code>CREATE DATABASE bylw;# 创建bylw数据库
USE bylw;
#source bylw.sql;# 导入数据文件,bylw.sql应替换成具体的路径,路径不能出现中文。也可以通过springboot配置导入
</code></pre></div><h3 id="创建用户和授予权限"><a href="#创建用户和授予权限" class="header-anchor">#</a> 创建用户和授予权限</h3> <div class="language-mysql extra-class"><pre class="language-text"><code>CREATE USER `developer`@`127.0.0.1` IDENTIFIED BY '123456';# 创建开发者用户,密码为123456,仅对本地运行有效
GRANT ALL PRIVILEGES ON `bylw`.* TO `developer`@`127.0.0.1`;# 给developer用户授予在bylw数据库上的所有权限

</code></pre></div><h2 id="创建springboot工程"><a href="#创建springboot工程" class="header-anchor">#</a> 创建springboot工程</h2> <p>idea自带spring initializr，可以直接通过idea创建springboot工程</p> <h3 id="通过该方式创建工程的作用"><a href="#通过该方式创建工程的作用" class="header-anchor">#</a> 通过该方式创建工程的作用：</h3> <ol><li>建立springboot的最简目录结构</li> <li>定制pom.xml（选择maven构建）</li></ol> <h3 id="创建过程"><a href="#创建过程" class="header-anchor">#</a> 创建过程</h3> <ol><li><p>新建工程，选择spring initializer，下一步</p></li> <li><p>配置项目元数据</p> <ul><li>group和artifact一般对应包名和web app名</li> <li>类型选择maven project</li> <li>语言是java</li> <li>打包方式在开发时选择jar（这些设置都可以在后面的pom.xml轻易修改），下一步</li> <li>勾选需要的依赖
<ul><li>springboot选择2.3.1</li> <li>deveoper tools全选</li> <li>web选择spring web</li> <li>template engines选择thymeleaf</li> <li>SQL选择mybatis framework和mysql driver</li></ul></li> <li>给project起名，完成</li></ul> <p>勾选的组件会在 <code>pom.xml</code>被声明，你可以根据需要修改pom.xml进行依赖的增加或删除</p></li></ol> <p><img src="/assets/img/image-20200715192742500.f9a898ed.png" alt="image-20200715192742500"></p> <p>其余图略</p> <p>springboot开发工具支持热重启，但不是说改了java源码就可以在浏览器上体现出来，依旧需要重新编译，但是再次编译生成的速度会比关闭热重启时快很多</p> <div class="language-xml extra-class"><pre class="language-xml"><code>        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.springframework.boot<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spring-boot-devtools<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>scope</span><span class="token punctuation">&gt;</span></span>runtime<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>scope</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>optional</span><span class="token punctuation">&gt;</span></span>true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>optional</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h3 id="项目目录架构-自行创建"><a href="#项目目录架构-自行创建" class="header-anchor">#</a> 项目目录架构（自行创建）</h3> <div class="language- extra-class"><pre class="language-text"><code>src/main/java/yourpackage
├─bean：存放实体类
├─controller：存放控制器，用于绑定路由和调用service
├─service：业务逻辑接口
│  └─impl：业务逻辑接口的实现
├─mapper：mybatis自定义接口，做sql语句与CURD方法的绑定
├─constant：存放全局常量，如果不需要可以省略
├─config：存放配置类
└─util：存放实用的辅助类

</code></pre></div><div class="language- extra-class"><pre class="language-text"><code>resources：资源文件夹，该目录下的application.properties和application.yml是配置文件，作用于整个项目
├─sql：存放sql文件，通过配置可以使mysql运行sql文件
├─public：存放可以通过url访问到的资源，如用户上传的文件
├─static：存放静态资源
│  ├─images
│  ├─css
│  └─js
└─templates：存放页面模板文件（html文件）
    └─errors：存放页面出错页模板文件（文件命名为状态码.html, 如4xx.html可以匹配所有状态码以4开头的错误)
</code></pre></div><h3 id="配置文件"><a href="#配置文件" class="header-anchor">#</a> 配置文件</h3> <p>在resources文件夹创建<code>application.yml</code></p> <div class="language-yaml extra-class"><pre class="language-yaml"><code><span class="token key atrule">spring</span><span class="token punctuation">:</span>
  <span class="token key atrule">profiles</span><span class="token punctuation">:</span>
<span class="token comment">#    开发调试时用develop,部署时应切换到product</span>
    <span class="token key atrule">active</span><span class="token punctuation">:</span> develop
<span class="token key atrule">logging</span><span class="token punctuation">:</span>
  <span class="token key atrule">file</span><span class="token punctuation">:</span>
    <span class="token key atrule">path</span><span class="token punctuation">:</span> log
<span class="token punctuation">---</span>
<span class="token comment">#开发环境</span>
<span class="token key atrule">server</span><span class="token punctuation">:</span>
  <span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">80</span>
<span class="token key atrule">spring</span><span class="token punctuation">:</span>
  <span class="token key atrule">profiles</span><span class="token punctuation">:</span>
    <span class="token key atrule">profile</span><span class="token punctuation">:</span> develop

  <span class="token key atrule">datasource</span><span class="token punctuation">:</span>
    <span class="token key atrule">username</span><span class="token punctuation">:</span> developer
    <span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token number">123456</span>

    <span class="token key atrule">url</span><span class="token punctuation">:</span> jdbc<span class="token punctuation">:</span>mysql<span class="token punctuation">:</span>//127.0.0.1<span class="token punctuation">:</span>3306/bylw<span class="token punctuation">?</span>serverTimezone=GMT%2B8
<span class="token comment">#    driver-class-name: com.mysql.cj.jdbc.Driver</span>
<span class="token comment">#    schema:</span>
<span class="token comment">#      - classpath:sql/bylw.sql</span>
    <span class="token key atrule">initialization-mode</span><span class="token punctuation">:</span> always

  <span class="token key atrule">thymeleaf</span><span class="token punctuation">:</span>
    <span class="token key atrule">cache</span><span class="token punctuation">:</span> <span class="token boolean important">false</span>
<span class="token punctuation">---</span>
<span class="token comment">#生产环境</span>
<span class="token key atrule">spring</span><span class="token punctuation">:</span>
     <span class="token key atrule">profiles</span><span class="token punctuation">:</span>
       <span class="token key atrule">profile</span><span class="token punctuation">:</span> product
<span class="token comment"># 需要根据实际生产环境配置，此处略</span>
</code></pre></div><h3 id="html页面要求"><a href="#html页面要求" class="header-anchor">#</a> html页面要求</h3> <p>为了能在idea中使用thymeleaf的代码提示，需要在html标签中添加xml命名空间</p> <div class="language-html extra-class"><pre class="language-html"><code><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>en<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>th</span> <span class="token attr-value"><span class="token punctuation attr-equals">=</span> <span class="token punctuation">&quot;</span>http://www.thymeleaf.org<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>。。。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><h2 id="测试"><a href="#测试" class="header-anchor">#</a> 测试</h2> <ol><li>用户权限测试（是否出现越权访问资源等情况）</li> <li>常见安全漏洞测试，xss，csrf，sql注入等</li> <li>检查用户密码是否经过加密处理：密文=md5(明文+salt值)</li> <li>业务流程测试（使用自动化测试工具如python的selenium模拟浏览器操作检查响应是否符合预期）</li> <li>错误页测试（对不同的错误状态码是否返回合理的页面）</li></ol> <h2 id="部署注意事项"><a href="#部署注意事项" class="header-anchor">#</a> 部署注意事项</h2> <ol><li>application.yml里的profile应从develop切换至product</li> <li>检查product profile的datasource，thymeleaf，server等是否正确配置</li> <li>支持https</li></ol> <h2 id="前后端分离-不分离"><a href="#前后端分离-不分离" class="header-anchor">#</a> 前后端分离/不分离</h2> <p>前后端不分离，就是使用页面模板渲染引擎，html页面模板会包含一些特殊变量，启动web服务器交给程序渲染后变量会被替换成数据，生成真正的html返回给浏览器。优点：对于前后端都是一个人搞的小项目该方式比较简单，通过模板渲染引擎的布局和继承等功能可以让html的代码量大大减少，且由于返回的html都是填好数据的页面，对静态爬虫友好。缺点：前后端强行分开很麻烦，效率不高，仅适合分模块后前后端一起弄的团队，且需要团队有人熟练掌握模板渲染引擎的用法。</p> <p>前后端分离，不用模板渲染引擎，成功的核心是接口规范的统一，前端专心做界面，通过js获取restful接口数据并填充到指定的dom结点，vue.js等框架可以很好做到这一点。后端专心写restful接口，后端只负责返回数据（大多时候是json文件）。优点：前后端可以完全独立，低耦合，后端做的东西也能被其他app使用。缺点：数据是异步加载的，对静态爬虫不友好，如果前后端本就是一个人做，依旧搞分离会增加工作量。</p></div> <footer class="page-edit"><!----> <!----> <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh"><img alt="知识共享许可协议" src="" style="border-width:0"></a><br>本作品采用<a rel="license" href="http://creativecommons.org/licenses/by/4.0/">知识共享署名 4.0 国际许可协议</a>进行许可。

   
</footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/知识点总结/PS总结.html" class="prev">
        PS总结
      </a></span> <span class="next"><a href="/知识点总结/thinkphp总结.html">
        thinkphp入坑
      </a>
      →
    </span></p></div>  <footer style="text-align:center;"><a href="https://beian.miit.gov.cn">
    粤ICP备2021020303号</a></footer></main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.54ea76a2.js" defer></script><script src="/assets/js/2.c554ece5.js" defer></script><script src="/assets/js/24.87aae001.js" defer></script>
  </body>
</html>
